package com.cy.springbootemep.controller;

import com.cy.springbootemep.pojo.Emp;
import com.cy.springbootemep.service.EmpService;
import com.cy.springbootemep.util.JsonResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

@Controller
@RestController
public class EmpController {
    @Autowired
    EmpService empService;

    @GetMapping("/select1")

    public JsonResult selec() {

        return new JsonResult(empService.selec());
    }

    @GetMapping("/select1Id")
    public JsonResult selecall(Integer id) {
        return new JsonResult(empService.seleall(id));
    }


    @GetMapping("/select1tj")

    public JsonResult selecitj(Emp emp) {

        return new JsonResult(empService.seleall3(emp));
    }

    @GetMapping("/select1tjs")

    public JsonResult selecitjs(Integer[] ids) {

        return new JsonResult(empService.seleall2(ids));
    }

    @PutMapping("/update")

    public JsonResult updat(Emp emp) {
        return new JsonResult(empService.upda(emp));
    }

    @PostMapping("/insert1")

    public JsonResult insert1(Emp emp) {
        return new JsonResult(empService.inser(emp));
    }

    @DeleteMapping("/delect1")

    public JsonResult delect1(Integer[] ids) {
        return new JsonResult(empService.de(ids));
    }
}
